jsx3.Class.defineClass(
		'tibco.admin.monitormanage.uicomponents.misc.browseWindowShade.BrowseWindowShade', // full name of the class to create
		jsx3.gui.Block, //  extends jsx3.lang.Object
		null, // does not implements any interfaces
		function(windowshade)
		{  // name the argument of this function "Example"
			/*
						 A WindowSahde object contains a 2-D jsx3.gui.LayoutGrid.
						 First pane is reserved for the content and the second pain contains a button for scrolling down and up.
						*/

			// Create a new logger or returns a pre-existing logger of the same name.
			windowshade.LOGGER = jsx3.util.Logger.getLogger("tibco.admin.monitormanage.uicomponents.misc.windowShade.WindowShade");
			// Set the level of this Logger.
			windowshade.LOGGER.setLevel(jsx3.util.Logger.ERORR);

			windowshade.prototype._maxHeight = 250;


			windowshade.prototype._setHeight = function(height)
			{
				this.height = height;
				this.windowShade.setHeight(height, true);
			}

			windowshade.prototype._setTop = function(top)
			{
				this._top = top
				this.windowShade.setTop(top, true)
			}

			windowshade.prototype._setDuration = function(duration)
			{
				this.duration = duration;
			}

			windowshade.prototype._setTimeout = function(timeout)
			{
				this.timeout = timeout;
			}

			windowshade.prototype._getTop = function()
			{
				return this._top;
			}

			windowshade.prototype._getDuration = function()
			{
				return this.duration;
			}


			windowshade.prototype._getTimeout = function()
			{
				return this.timeout;
			}

			windowshade.DEFAULTTIMEOUT = 50;

			windowshade.DEFAULTDURATION = 500;

			windowshade.DEFAULTDIRECTION = 1;


			windowshade.prototype.init = function(strName, vntLeft, vntTop, vntWidth, vntHeight)
			{
				//call constructor for super class
				this.jsxsuper(strName, vntLeft, vntTop, vntWidth, vntHeight);
				this.setDuration(windowshade.DEFAULTDURATION);
				this.setTimeout(windowshade.DEFAULTTIMEOUT);
				this.setDirection(windowshade.DEFAULTDIRECTION);
			};

			/**
			 *
			 * @returns {int}
			 */
			windowshade.prototype.getDuration = function()
			{
				return this.duration;
			};


			/**
			 *
			 * @param intDuration {int}
			 * @returns {tibco.admin.monitormanage.uicomponents.misc.windowShade.WindowShade} this object
			 */
			windowshade.prototype.setDuration = function(intDuration)
			{
				this.duration = intDuration;
				return this;
			};


			/**
			 *
			 * @returns {int}
			 */
			windowshade.prototype.getTimeout = function()
			{
				return this.timeout;
			};


			/**
			 *
			 * @param intDuration {int}
			 * @returns {tibco.admin.monitormanage.uicomponents.misc.windowShade.WindowShade} this object
			 */
			windowshade.prototype.setTimeout = function(intTimeout)
			{
				this.timeout = intTimeout;
				return this;
			};


			windowshade.prototype.getDirection = function()
			{
				return this.direction;
			}


			windowshade.prototype.setDirection = function(intDirection)
			{
				this.direction = intDirection;
				return this
			}

			windowshade.prototype.getDistance = function()
			{
				return this.distance;
			}


			windowshade.prototype.setDistance = function(intDistance)
			{
				this.distance = intDistance;
				return this
			}

			/*******************************************************************
			 * Added the following method - BT
			 *******************************************************************/
			windowshade.prototype.onAfterAssemble = function(objParent, objServer)
			{
				this.initializeParameters(null, null, null, objParent);
			}

			windowshade.prototype.initializeParameters = function(intDirection, intTimeout, intDuration, objParent)
			{
				try {
					intDirection = (intDirection)?intDirection: windowshade.DEFAULTDIRECTION
					intTimeout = (intTimeout)?intTimeout: windowshade.DEFAULTTIMEOUT
					intDuration = (intDuration)?intDuration: windowshade.DEFAULTDURATION

					// Set the scroll direction to default
					this.setDirection(intDirection);

					this.setTimeout(intTimeout);
					this.setDuration(intDuration);

					// Get the parent height
					var parent = objParent;
					if (!parent)
					{
						parent = this.getParent();
					}
					var parentHeight = parent.getRendered().style.height;
					var parentHeightInt = parseInt(parentHeight.replace("px", ""));
					parentHeightInt = parentHeightInt - 2;

					if (this._maxHeight && parentHeightInt > this._maxHeight)
					{
						parentHeightInt = this._maxHeight;
					}

					// Get the window shade dimension
					var lytWindowShade = this.getDescendantOfName("lytWindowShade", false, false) ;
					var lytWindowShadeDimensionArray = lytWindowShade.getDimensionArray();

					// set the distance to scroll
					var temp = lytWindowShadeDimensionArray[1] - parentHeightInt;
					this.setDistance(Math.abs(temp));

					// Initialize the window shade top
					var tempTop = 0;
					if (intDirection == 1)
						tempTop = temp

					//set the window shade top
					this.setTop(tempTop, false).setHeight(parentHeightInt, true);

					// set the fragment. round it down
					this.fragment = Math.round(((this.getDistance() * this.getTimeout()) / this.getDuration()) - 0.5);

					// Set the scroll end point
					this._calcScrollEndPoint(this.getDirection());

				}
				catch
					(e)
				{
					windowshade.LOGGER.error("Error setting parameters:\n" + e.description + "\n" + e);
				}
			}


			windowshade.prototype._scrollWindowVertical = function(fragment, endpoint, currentTop)
			{
				var newTop = currentTop + fragment;
				this.rendered.style.top = newTop
				if (this.direction * newTop < endpoint) {
					var me = this
					setTimeout(function()
					{
						me._scrollWindowVertical(fragment, endpoint, newTop)
					}, this.timeout);
				}
				else {
					this._switchDirection();
					this.initializeParameters(this.getDirection(), this.getTimeout(), this.getDuration())
				}
			}

			windowshade.prototype.scrollWindowVertical = function()
			{
				var fragment = this.fragment * this.direction
				var endpoint = this.direction * this.scrollEndpoint
				this.rendered = this.getRendered()
				this._scrollWindowVertical(fragment, endpoint, this.getTop());
				/*******************************************************************
				 * Added the following code - BT
				 *******************************************************************/

				// handle the browse label and masking
				var contentPaneForMasking = this.findContentPaneForMasking();
				var browseLabel = this.getDescendantOfName("browseLabel_MM_brws");
				var browseBtn = this.getDescendantOfName("paneBrowseBtn_MM_brws");
				var paneBrowseBtn = this.getDescendantOfName("paneBrowseBtn_MM_brws") ;
				var browseOpenVal, browseBtnBg;
				if (this.direction == -1)
				{
					browseLabelText = tibco.admin.Main.getServer().getDynamicProperty("@MM@general@browseLabel");
					browseBtnBg = tibco.admin.Main.getServer().getDynamicProperty("@MM@general@winPaneBrowseTabBGImage");
					browseOpenVal = false;
					this.cachedMaskedComponent.hideMask();
					this.cachedMaskedComponent = null;
					tibco.admin.monitormanage.general.PollingHandler.unpausePolling();
				}
				else
				{
					this.loadComponent();
					browseOpenVal = true;
					browseLabelText = tibco.admin.Main.getServer().getDynamicProperty("@MM@general@closeLabel") + " ";
					browseBtnBg = tibco.admin.Main.getServer().getDynamicProperty("@MM@general@winPaneCloseTabBGImage");
					contentPaneForMasking.showMask();
					this.cachedMaskedComponent = contentPaneForMasking;
					tibco.admin.monitormanage.general.PollingHandler.pausePolling();
				}
				var message = { browseOpen:browseOpenVal };
				tibco.admin.monitormanage.general.PageBusUtils.publish(windowshade.browseOpenCloseSubject, message);

				browseLabel.setText(browseLabelText);
				browseBtn.setBackground(browseBtnBg);
				paneBrowseBtn.repaint();
			}


			windowshade.prototype._calcScrollEndPoint = function (intDirection)
			{
				this.scrollEndpoint = this.getTop() + (intDirection * this.getDistance());
			}

			windowshade.prototype._switchDirection = function()
			{
				this.setDirection(this.getDirection() * -1)
			}

			windowshade.instance = null

			windowshade.getInstance = function(args)
			{
				if (!this.instance) {
					this.instance = new tibco.admin.monitormanage.uicomponents.misc.browseWindowShade.BrowsePaneInterface();
				}
				return this.instance;
			}

			/*******************************************************************
			 * The code above is windowshade behavior specific                 *
			 * The code below is specific to the components in the windowshade *
			 *******************************************************************/

			windowshade.wsEndpointURL = tibco.admin.monitormanage.framework.mainPage.MainPage.wsEndpointURL;

			windowshade.browseOpenCloseSubject = "com.tibco.admin.monitormanage.uicomponents.misc.browseWindowShade.BrowseWindowShade.browseOpenCloseSubject";

			windowshade.allId = "ALL_ID";

			windowshade.browseModeGrid = "gridInfrastructureView";
			windowshade.browseModeDeploy = "deployView";

			windowshade.gridViewLayoutName = "gridViewLayout";
			windowshade.deploymentViewLayoutName = "deploymentViewLayout";

			windowshade.browseEnvironmentsCacheId = "SPM_BROWSE_ENVIRONMENTS_CACHE";
			windowshade.browseMachinesCacheId = "SPM_BROWSE_MACHINES_CACHE";
			windowshade.browseNodesCacheId = "SPM_BROWSE_NODES_CACHE";
			windowshade.browseServiceAssembliesCacheId = "SPM_BROWSE_SERVICE_ASSEMBLIES_CACHE";
			windowshade.browseServiceUnitsCacheId = "SPM_BROWSE_SERVICE_UNITS_CACHE";

			windowshade.environmentSelected = "environmentListItemSelected";
			windowshade.machineSelected = "machineListItemSelected";
			windowshade.nodeSelected = "nodeListItemSelected";
			windowshade.serviceAssemblySelected = "serviceAssemblyListItemSelected";
			windowshade.serviceUnitSelected = "serviceUnitListItemSelected";

			windowshade.prototype.isGridMode;
			windowshade.prototype.currentDeployItemTypeSelected;
			windowshade.prototype.currentGridItemTypeSelected;

			windowshade.prototype.currentlySelectedDeployEnvironmentKey;
			windowshade.prototype.currentlySelectedGridEnvironmentKey;
			windowshade.prototype.currentlySelectedMachineKey;
			windowshade.prototype.currentlySelectedNodeKey;
			windowshade.prototype.currentlySelectedServiceAssemblyKey;
			windowshade.prototype.currentlySelectedServiceUnitKey;

			windowshade.prototype.currentlySelectedDeployEnvironmentName;
			windowshade.prototype.currentlySelectedGridEnvironmentName;
			windowshade.prototype.currentlySelectedMachineName;
			windowshade.prototype.currentlySelectedNodeName;
			windowshade.prototype.currentlySelectedServiceAssemblyName;
			windowshade.prototype.currentlySelectedServiceUnitName;

			windowshade.prototype.cachedMaskedComponent;

			windowshade.prototype.getNamespace = function()
			{
				return "tibco.admin";
			}

			windowshade.prototype.setUpComponent = function(obj)
			{
				this.isGridMode = true;
				this.currentDeployItemTypeSelected = null;
				this.currentGridItemTypeSelected = null;
				this.currentlySelectedDeployEnvironmentKey = null;
				this.currentlySelectedGridEnvironmentKey = null;
				this.currentlySelectedMachineKey = null;
				this.currentlySelectedNodeKey = null;
				this.currentlySelectedServiceAssemblyKey = null;
				this.currentlySelectedServiceUnitKey = null;
				this.currentlySelectedDeployEnvironmentName = null;
				this.currentlySelectedGridEnvironmentName = null;
				this.currentlySelectedMachineName = null;
				this.currentlySelectedNodeName = null;
				this.currentlySelectedServiceAssemblyName = null;
				this.currentlySelectedServiceUnitName = null;
				this.cachedMaskedComponent = null;

				// subscribe to find out when the main page navigation tab is clicked
				var subject = tibco.admin.monitormanage.framework.mainPage.MainPageInterface.mainPageTabClickedSubject;
				tibco.admin.monitormanage.general.PageBusUtils.subscribe(subject, this.mainPageTabClicked, this);

				//set browser label text
				var browseLabel = this.getDescendantOfName("browseLabel_MM_brws");
				var	browseLabelText = tibco.admin.Main.getServer().getDynamicProperty("@MM@general@wsLblBrowse");
				browseLabel.setText(browseLabelText);

				//set browse btn background
				var browseBtn = this.getDescendantOfName("paneBrowseBtn_MM_brws");
				var	browseBtnBg = tibco.admin.Main.getServer().getDynamicProperty("@MM@general@winPaneBrowseTabBGImage");
				browseBtn.setBackground(browseBtnBg);
				browseBtn.repaint();

				var closeWindowImg = this.getDescendantOfName("closeWindowImg_MM_brws");
				closeWindowImg.repaint();
			}

			windowshade.prototype.mainPageTabClicked = function(subject, message, windowshadeObj)
			{
				// a Main Page navigational tab was clicked so close the window if necessary
				if (windowshadeObj.getDirection() == -1)
				{
					windowshadeObj.scrollWindowVertical();
				}
			}

			windowshade.prototype.loadComponent = function()
			{
				this.isGridMode = true;
				this.currentDeployItemTypeSelected = null;
				this.currentGridItemTypeSelected = null;

				this.currentlySelectedDeployEnvironmentKey = null;
				this.currentlySelectedGridEnvironmentKey = null;
				this.currentlySelectedMachineKey = null;
				this.currentlySelectedNodeKey = null;
				this.currentlySelectedServiceAssemblyKey = null;
				this.currentlySelectedServiceUnitKey = null;

				this.currentlySelectedDeployEnvironmentName = null;
				this.currentlySelectedGridEnvironmentName = null;
				this.currentlySelectedMachineName = null;
				this.currentlySelectedNodeName = null;
				this.currentlySelectedServiceAssemblyName = null;
				this.currentlySelectedServiceUnitName = null;

				var cache = tibco.admin.Main.getServer().Cache;
				cache.clearById(windowshade.browseMachinesCacheId);
				cache.clearById(windowshade.browseNodesCacheId);
				cache.clearById(windowshade.browseServiceAssembliesCacheId);
				cache.clearById(windowshade.browseServiceUnitsCacheId);
				// don't think I should have to do these repaints but the tables weren't repainting with the clearById call above
				this.getDescendantOfName("machineList_MM_brws").repaint();
				this.getDescendantOfName("nodesList_MM_brws").repaint();
				this.getDescendantOfName("serviceAssemblyList_MM_brws").repaint();
				this.getDescendantOfName("serviceUnitList_MM_brws").repaint();

				this.updateButtonText(null, true);

				this.callGetEnvironments();
				//   this.getDescendantOfName("browseHelpImg_MM_brws").subscribe(jsx3.gui.Interactive.EXECUTE,this,this.helpImgClicked);
				this.getDescendantOfName("browseHelpImg_MM_brws").setEvent("this.getAncestorOfName('blkWindowShade').helpImgClicked(objEVENT)", "jsxexecute");
			}

			windowshade.prototype.helpImgClicked = function (objEVENT)
			{
				if (this.isGridMode)
					this.getDescendantOfName("browseHelpImg_MM_brws").openHelp("MonitorManage.Infrastructure.Browse ", "tibco.admin", objEVENT);
				else
					this.getDescendantOfName("browseHelpImg_MM_brws").openHelp("MonitorManage.Deployment.Browse  ", "tibco.admin", objEVENT);
			}

			windowshade.prototype.findContentPaneForMasking = function()
			{
				var siblingsArray = this.getParent().getChildren();
				var foundContentPane;
				for (i = 0; i < siblingsArray.length; i++)
				{
					var siblingObj = siblingsArray[i];
					if (siblingObj != this && siblingObj.getDisplay() == jsx3.gui.Block.DISPLAYBLOCK)
					{
						foundContentPane = siblingObj;
						break;
					}
				}
				return foundContentPane.getChild(0);
			}

			windowshade.prototype.setBrowseMode = function(mode)
			{
				var layoutNameToHide;
				var layoutNameToDisplay;
				if (mode == windowshade.browseModeGrid)
				{
					layoutNameToHide = windowshade.deploymentViewLayoutName;
					layoutNameToDisplay = windowshade.gridViewLayoutName;
					this.isGridMode = true;
				}
				else
				{
					layoutNameToHide = windowshade.gridViewLayoutName;
					layoutNameToDisplay = windowshade.deploymentViewLayoutName;
					this.isGridMode = false;
				}

				this.getDescendantOfName(layoutNameToHide).setDisplay(jsx3.gui.Block.DISPLAYNONE);
				var layoutToDisplay = this.getDescendantOfName(layoutNameToDisplay);
				layoutToDisplay.setDisplay(jsx3.gui.Block.DISPLAYBLOCK);
				layoutToDisplay.getParent().repaint();

				// clear the selected item in the environments list and select the correct value
				var environmentsList = layoutToDisplay.getDescendantOfName("environmentList_MM_brws");
				environmentsList.deselectAllRecords();
				if (this.isGridMode)
				{
					if (this.currentlySelectedGridEnvironmentKey)
					{
						environmentsList.selectRecord(this.currentlySelectedGridEnvironmentKey);
					}
				}
				else
				{
					if (this.currentlySelectedDeployEnvironmentKey)
					{
						environmentsList.selectRecord(this.currentlySelectedDeployEnvironmentKey);
					}
				}
				environmentsList.repaint();

				// handle the text of the view buttons
				var buttonText;
				var server = tibco.admin.Main.getServer();
				var allItemSelected = false;
				if (this.isGridMode)
				{
					if (this.currentGridItemTypeSelected == windowshade.environmentSelected)
					{
						buttonText = server.getDynamicProperty("@MM@general@wsLblEnvironment");
						if (this.currentlySelectedGridEnvironmentKey == windowshade.allId)
						{
							allItemSelected = true;
						}
					}
					else if (this.currentGridItemTypeSelected == windowshade.machineSelected)
					{
						buttonText = server.getDynamicProperty("@MM@general@lblMachine");
						if (this.currentlySelectedMachineKey == windowshade.allId)
						{
							allItemSelected = true;
						}
					}
					else if (this.currentGridItemTypeSelected == windowshade.nodeSelected)
					{
						if (this.currentlySelectedNodeKey == windowshade.allId)
						{
							allItemSelected = true;
						}
						buttonText = server.getDynamicProperty("@MM@general@lblNode");
					}
				}
				else
				{
					if (this.currentDeployItemTypeSelected == windowshade.environmentSelected)
					{
						buttonText = server.getDynamicProperty("@MM@general@wsLblEnvironment");
						if (this.currentlySelectedDeployEnvironmentKey == windowshade.allId)
						{
							allItemSelected = true;
						}
					}
					else if (this.currentDeployItemTypeSelected == windowshade.serviceAssemblySelected)
					{
						if (this.currentlySelectedServiceAssemblyKey == windowshade.allId)
						{
							allItemSelected = true;
						}
						buttonText = server.getDynamicProperty("@MM@general@lblServiceAssembly");
					}
					else if (this.currentDeployItemTypeSelected == windowshade.serviceUnitSelected)
					{
						if (this.currentlySelectedServiceUnitKey == windowshade.allId)
						{
							allItemSelected = true;
						}
						buttonText = server.getDynamicProperty("@MM@general@wsLblSvcUnit");
					}
				}
				this.updateButtonText(buttonText, allItemSelected);
			}

			windowshade.prototype.listItemSelected = function(selectedType, id, tableObj)
			{
				var server = tibco.admin.Main.getServer();
				var objTypeText;
				var cacheIdToRemove;
				var tableNameToClear;

				// retrieve the name of the selected record
				var selectedName = null;
				var selectedRecords = tableObj.getSelectedNodes();
				if (selectedRecords.size() > 0)
				{
					selectedName = selectedRecords.get(0).getAttribute("jsxtext");
				}

				if (selectedType == windowshade.environmentSelected)
				{
					if (this.isGridMode)
					{
						this.callGetMachines(id);
						cacheIdToRemove = windowshade.browseNodesCacheId;
						tableNameToClear = "nodesList_MM_brws";
						this.currentlySelectedGridEnvironmentKey = id;
						this.currentlySelectedGridEnvironmentName = selectedName;
						this.currentGridItemTypeSelected = selectedType;

						this.currentlySelectedMachineKey = null;
						this.currentlySelectedNodeKey = null;
					}
					else
					{
						this.callGetServiceAssemblies(id);
						cacheIdToRemove = windowshade.browseServiceUnitsCacheId;
						tableNameToClear = "serviceUnitList_MM_brws";
						this.currentlySelectedDeployEnvironmentKey = id;
						this.currentlySelectedDeployEnvironmentName = selectedName;
						this.currentDeployItemTypeSelected = selectedType;

						this.currentlySelectedServiceAssemblyKey = null;
						this.currentlySelectedServiceUnitKey = null;
						this.currentlySelectedServiceAssemblyName = null;
						this.currentlySelectedServiceUnitName = null;
					}

					objTypeText = server.getDynamicProperty("@MM@general@wsLblEnvironment");
				}
				else if (selectedType == windowshade.machineSelected)
				{
					this.callGetNodes(this.currentlySelectedGridEnvironmentKey, id);
					objTypeText = server.getDynamicProperty("@MM@general@lblMachine");
					this.currentlySelectedMachineKey = id;
					this.currentlySelectedMachineName = selectedName;
					this.currentlySelectedNodeKey = null;
					this.currentlySelectedNodeName = null;
					this.currentGridItemTypeSelected = selectedType;
				}
				else if (selectedType == windowshade.nodeSelected)
				{
					objTypeText = server.getDynamicProperty("@MM@general@lblNode");
					this.currentlySelectedNodeKey = id;
					this.currentlySelectedNodeName = selectedName;
					this.currentGridItemTypeSelected = selectedType;
				}
				else if (selectedType == windowshade.serviceAssemblySelected)
				{
					this.callGetServiceUnits(this.currentlySelectedDeployEnvironmentKey, id);
					objTypeText = server.getDynamicProperty("@MM@general@lblServiceAssembly");
					this.currentlySelectedServiceAssemblyKey = id;
					this.currentlySelectedServiceAssemblyName = selectedName;
					this.currentlySelectedServiceUnitKey = null;
					this.currentlySelectedServiceUnitName = null;
					this.currentDeployItemTypeSelected = selectedType;
				}
				else if (selectedType == windowshade.serviceUnitSelected)
				{
					objTypeText = server.getDynamicProperty("@MM@general@wsLblSvcUnit");
					this.currentlySelectedServiceUnitKey = id;
					this.currentlySelectedServiceUnitName = selectedName;
					this.currentDeployItemTypeSelected = selectedType;
				}

				// remove the data from the list if it no longer applies to the current selection
				if (cacheIdToRemove)
				{
					tibco.admin.Main.getServer().Cache.clearById(cacheIdToRemove);
					this.getDescendantOfName(tableNameToClear).repaint();
				}

				// now update the button text
				var disableViewButton = false;
				if (id == windowshade.allId)
				{
					disableViewButton = true;
				}
				this.updateButtonText(objTypeText, disableViewButton);
			}

			windowshade.prototype.updateButtonText = function(objTypeText, disableViewButton)
			{
				var server = tibco.admin.Main.getServer();
				var viewItemButton = this.getDescendantOfName("viewItemButton_MM_brws");
				var viewItemButtonText = server.getDynamicProperty("@MM@general@wsLblView") + " ";
				var viewButtonState = jsx3.gui.Form.STATEENABLED;
				if (objTypeText)
				{
					viewItemButtonText += objTypeText;
					if (disableViewButton)
					{
						viewButtonState = jsx3.gui.Form.STATEDISABLED;
					}
				}
				else
				{
					viewButtonState = jsx3.gui.Form.STATEDISABLED;
				}
				viewItemButton.setText(viewItemButtonText);
				viewItemButton.setEnabled(viewButtonState);

				var viewServicesButton = this.getDescendantOfName("viewServicesButton_MM_brws");
				var prefixText;
				if (this.isGridMode)
				{
					prefixText = server.getDynamicProperty("@MM@general@wsLblViewServiceInstances");
				}
				else
				{
					prefixText = server.getDynamicProperty("@MM@general@wsLblViewServices");
				}
				var viewServicesButtonText = prefixText;
				if (objTypeText)
				{
					viewServicesButtonText += " " + server.getDynamicProperty("@MM@general@lowerCaseOnLabel") + " " + objTypeText;
					viewServicesButton.setEnabled(jsx3.gui.Form.STATEENABLED);
				}
				else
				{
					viewServicesButton.setEnabled(jsx3.gui.Form.STATEDISABLED);
				}
				viewServicesButton.setText(viewServicesButtonText);

				viewItemButton.repaint();
				viewServicesButton.repaint();
			}

			windowshade.prototype.viewSelectedItem = function()
			{

				// navigate to the appropriate screen
				var nextNavScreenId;
				var paramArray = {};
				var objIdToView;
				if (this.isGridMode)
				{
					if (this.currentGridItemTypeSelected == windowshade.environmentSelected)
					{
						nextNavScreenId = tibco.admin.monitormanage.uicomponents.page.gridInfrastructure.GridInfrastructure.environmentScreenId;
						paramArray.environmentId = this.currentlySelectedGridEnvironmentKey;
					}
					else if (this.currentGridItemTypeSelected == windowshade.machineSelected)
					{
						nextNavScreenId = tibco.admin.monitormanage.uicomponents.page.gridInfrastructure.GridInfrastructure.machineScreenId;
						paramArray.machineId = this.currentlySelectedMachineKey;
					}
					else if (this.currentGridItemTypeSelected == windowshade.nodeSelected)
					{
						nextNavScreenId = tibco.admin.monitormanage.uicomponents.page.gridInfrastructure.GridInfrastructure.nodeScreenId;
						paramArray.nodeId = this.currentlySelectedNodeKey;
					}
				}
				else
				{
					if (this.currentDeployItemTypeSelected == windowshade.environmentSelected)
					{
						nextNavScreenId = tibco.admin.monitormanage.uicomponents.page.deployment.Deployment.environmentScreenId;
						paramArray.environmentId = this.currentlySelectedDeployEnvironmentKey;
					}
					else if (this.currentDeployItemTypeSelected == windowshade.serviceAssemblySelected)
					{
						nextNavScreenId = tibco.admin.monitormanage.uicomponents.page.deployment.Deployment.serviceAssemblyScreenId;
						paramArray.serviceAssemblyId = this.currentlySelectedServiceAssemblyKey;
					}
					else if (this.currentDeployItemTypeSelected == windowshade.serviceUnitSelected)
					{
						nextNavScreenId = tibco.admin.monitormanage.uicomponents.page.deployment.Deployment.serviceUnitScreenId;
						paramArray.serviceUnitId = this.currentlySelectedServiceUnitKey;
					}
				}
				tibco.admin.monitormanage.general.NavigationHandler.publishMainPageNavigationMessage(nextNavScreenId, paramArray);

				// close the browse window
				this.scrollWindowVertical();
			}

			windowshade.prototype.viewServices = function()
			{
				var paramArray = {};
				// pass the appropriate params to populate the screen
				var isServiceInstance;
				if (this.isGridMode)
				{
					isServiceInstance = true;
					if (this.currentGridItemTypeSelected == windowshade.environmentSelected)
					{
						paramArray.environmentId = this.currentlySelectedGridEnvironmentKey;
						paramArray.environmentName = this.currentlySelectedGridEnvironmentName;
					}
					else if (this.currentGridItemTypeSelected == windowshade.machineSelected)
					{
						paramArray.environmentId = this.currentlySelectedGridEnvironmentKey;
						paramArray.environmentName = this.currentlySelectedGridEnvironmentName;
						paramArray.machineId = this.currentlySelectedMachineKey;
						paramArray.machineName = this.currentlySelectedMachineName;
					}
					else if (this.currentGridItemTypeSelected == windowshade.nodeSelected)
					{
						paramArray.environmentId = this.currentlySelectedGridEnvironmentKey;
						paramArray.environmentName = this.currentlySelectedGridEnvironmentName;
						paramArray.machineId = this.currentlySelectedMachineKey;
						paramArray.machineName = this.currentlySelectedMachineName;
						paramArray.nodeId = this.currentlySelectedNodeKey;
						paramArray.nodeName = this.currentlySelectedNodeName;
					}
					jsx3.log("DEBUG: Browse panel passing: environment = " + paramArray.environmentName + ", machine = " + paramArray.machineName + ", and node = " + paramArray.nodeName);
				}
				else
				{
					isServiceInstance = false;
					if (this.currentDeployItemTypeSelected == windowshade.environmentSelected)
					{
						paramArray.environmentId = this.currentlySelectedDeployEnvironmentKey;
						paramArray.environmentName = this.currentlySelectedDeployEnvironmentName;
					}
					else if (this.currentDeployItemTypeSelected == windowshade.serviceAssemblySelected)
					{
						paramArray.environmentId = this.currentlySelectedDeployEnvironmentKey;
						paramArray.environmentName = this.currentlySelectedDeployEnvironmentName;
						paramArray.serviceAssemblyId = this.currentlySelectedServiceAssemblyKey;
						paramArray.serviceAssemblyName = this.currentlySelectedServiceAssemblyName;
					}
					else if (this.currentDeployItemTypeSelected == windowshade.serviceUnitSelected)
					{
						paramArray.environmentId = this.currentlySelectedDeployEnvironmentKey;
						paramArray.environmentName = this.currentlySelectedDeployEnvironmentName;
						paramArray.serviceAssemblyId = this.currentlySelectedServiceAssemblyKey;
						paramArray.serviceAssemblyName = this.currentlySelectedServiceAssemblyName;
						paramArray.serviceUnitId = this.currentlySelectedServiceUnitKey;
						paramArray.serviceUnitName = this.currentlySelectedServiceUnitName;
					}
					jsx3.log("DEBUG: Browse panel passing: environment = " + paramArray.environmentName + ", service assembly = " + paramArray.serviceAssemblyName + ", and service unit = " + paramArray.serviceUnitName);
				}

				paramArray.isServiceInstance = isServiceInstance;

				tibco.admin.monitormanage.general.NavigationHandler.publishMainPageNavigationMessage(tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceView.searchServicesScreenId, paramArray);

				// close the browse window
				this.scrollWindowVertical();
			}

			//call this method to begin the service call (eg.service.callgetEnvironments();)
			windowshade.prototype.callGetEnvironments = function()
			{
				var dataURI = "tibco/admin/monitormanage/uicomponents/misc/browseWindowShade/data/environmentData.xml";
				var rulesURI = "tibco/admin/monitormanage/uicomponents/misc/browseWindowShade/rules/environmentRules.xml";
				if (tibco.admin.Main.getServer().getEnv("MODE")) {
					// mode is live
					var objService = tibco.admin.Main.loadService(this.getNamespace(), rulesURI, "getEnvironments");
					objService.setEndpointURL(windowshade.wsEndpointURL);
					// this setInboundURL should not be required...only here because of a current AMX framework bug
					objService.setInboundURL(dataURI);
				}
				else {
					var objService = new jsx3.net.Service(tibco.admin.Main.resolveURI(this.getNamespace(), rulesURI), "getEnvironments", null, null);
					// mode is static
					objService.setInboundURL(tibco.admin.Main.resolveURI(this.getNamespace(), dataURI));
				}

				objService.browseWindowShadeObj = this;

				//subscribe and call
				objService.subscribe(jsx3.net.Service.ON_SUCCESS, this.ongetEnvironmentsSuccess);
				objService.subscribe(jsx3.net.Service.ON_ERROR, this.ongetEnvironmentsError);
				objService.subscribe(jsx3.net.Service.ON_INVALID, this.ongetEnvironmentsInvalid);
				objService.doCall();
			};

			windowshade.prototype.ongetEnvironmentsSuccess = function(objEvent)
			{
				//var responseXML = objEvent.target.getInboundDocument();
				//jsx3.log("Success","The service call was successful.");

				var browseWindowShadeObj = objEvent.target.browseWindowShadeObj;
				var layoutName;
				if (browseWindowShadeObj.isGridMode)
				{
					layoutName = windowshade.gridViewLayoutName;
				}
				else
				{
					layoutName = windowshade.deploymentViewLayoutName;
				}
				var layoutObj = browseWindowShadeObj.getDescendantOfName(layoutName);
				layoutObj.getDescendantOfName("environmentList_MM_brws").repaint();
			};

			windowshade.prototype.ongetEnvironmentsError = function(objEvent)
			{
				var myStatus = objEvent.target.getRequest().getStatus();
				jsx3.log("Error", "The service call failed. The HTTP Status code is: " + myStatus);
			}

			windowshade.prototype.ongetEnvironmentsInvalid = function(objEvent)
			{
				jsx3.log("Invalid", "The following message node just failed validation:\n\n" + objEvent.message);
			}

			//call this method to begin the service call (eg.service.callgetMachines();)
			windowshade.prototype.callGetMachines = function(envId)
			{
				var dataURI = "tibco/admin/monitormanage/uicomponents/misc/browseWindowShade/data/machineData.xml";
				var rulesURI = "tibco/admin/monitormanage/uicomponents/misc/browseWindowShade/rules/machineRules.xml";
				if (tibco.admin.Main.getServer().getEnv("MODE")) {
					// mode is live
					var objService = tibco.admin.Main.loadService(this.getNamespace(), rulesURI, "getMachines");
					objService.setEndpointURL(windowshade.wsEndpointURL);
					// this setInboundURL should not be required...only here because of a current AMX framework bug
					objService.setInboundURL(dataURI);
				}
				else {
					var objService = new jsx3.net.Service(tibco.admin.Main.resolveURI(this.getNamespace(), rulesURI), "getMachines", null, null);
					// mode is static
					objService.setInboundURL(tibco.admin.Main.resolveURI(this.getNamespace(), dataURI));
				}

				objService.browseWindowShadeObj = this;
				objService.environmentKey = envId;

				//subscribe and call
				objService.subscribe(jsx3.net.Service.ON_SUCCESS, this.ongetMachinesSuccess);
				objService.subscribe(jsx3.net.Service.ON_ERROR, this.ongetMachinesError);
				objService.subscribe(jsx3.net.Service.ON_INVALID, this.ongetMachinesInvalid);
				objService.doCall();
			};

			windowshade.prototype.ongetMachinesSuccess = function(objEvent)
			{
				//var responseXML = objEvent.target.getInboundDocument();
				//jsx3.log("Success","The service call was successful.");

				var browseWindowShadeObj = objEvent.target.browseWindowShadeObj;
				// add the "All" option to the cache
				var allMachinesLabel = tibco.admin.Main.getServer().getDynamicProperty("@MM@general@browseAllMachines");
				browseWindowShadeObj.addAllOption(windowshade.browseMachinesCacheId, allMachinesLabel);

				browseWindowShadeObj.getDescendantOfName("machineList_MM_brws").repaint();
			};

			windowshade.prototype.ongetMachinesError = function(objEvent)
			{
				var myStatus = objEvent.target.getRequest().getStatus();
				jsx3.log("Error", "The service call failed. The HTTP Status code is: " + myStatus);
			};

			windowshade.prototype.ongetMachinesInvalid = function(objEvent)
			{
				jsx3.log("Invalid", "The following message node just failed validation:\n\n" + objEvent.message);
			};

			//call this method to begin the service call (eg.service.callgetNodes();)
			windowshade.prototype.callGetNodes = function(envId, machineId)
			{
				var dataURI = "tibco/admin/monitormanage/uicomponents/misc/browseWindowShade/data/nodeData.xml";
				var rulesURI = "tibco/admin/monitormanage/uicomponents/misc/browseWindowShade/rules/nodeRules.xml";
				if (tibco.admin.Main.getServer().getEnv("MODE")) {
					// mode is live
					var objService = tibco.admin.Main.loadService(this.getNamespace(), rulesURI, "getNodes");
					objService.setEndpointURL(windowshade.wsEndpointURL);
					// this setInboundURL should not be required...only here because of a current AMX framework bug
					objService.setInboundURL(dataURI);
				}
				else {
					var objService = new jsx3.net.Service(tibco.admin.Main.resolveURI(this.getNamespace(), rulesURI), "getNodes", null, null);
					// mode is static
					objService.setInboundURL(tibco.admin.Main.resolveURI(this.getNamespace(), dataURI));
				}

				objService.browseWindowShadeObj = this;
				objService.environmentKey = envId;
				if (machineId == windowshade.allId)
				{
					objService.machineKey = "";
				}
				else
				{
					objService.machineKey = machineId;
				}

				//subscribe and call
				objService.subscribe(jsx3.net.Service.ON_SUCCESS, this.ongetNodesSuccess);
				objService.subscribe(jsx3.net.Service.ON_ERROR, this.ongetNodesError);
				objService.subscribe(jsx3.net.Service.ON_INVALID, this.ongetNodesInvalid);
				objService.doCall();
			};

			windowshade.prototype.ongetNodesSuccess = function(objEvent)
			{
				//var responseXML = objEvent.target.getInboundDocument();
				//jsx3.log("Success","The service call was successful.");

				var browseWindowShadeObj = objEvent.target.browseWindowShadeObj;
				browseWindowShadeObj.getDescendantOfName("nodesList_MM_brws").repaint();
			};

			windowshade.prototype.ongetNodesError = function(objEvent)
			{
				var myStatus = objEvent.target.getRequest().getStatus();
				jsx3.log("Error", "The service call failed. The HTTP Status code is: " + myStatus);
			};

			windowshade.prototype.ongetNodesInvalid = function(objEvent)
			{
				jsx3.log("Invalid", "The following message node just failed validation:\n\n" + objEvent.message);
			};

			//call this method to begin the service call (eg.service.callgetServiceAssemblies();)
			windowshade.prototype.callGetServiceAssemblies = function(envId)
			{
				var dataURI = "tibco/admin/monitormanage/uicomponents/misc/browseWindowShade/data/serviceAssemblyData.xml";
				var rulesURI = "tibco/admin/monitormanage/uicomponents/misc/browseWindowShade/rules/serviceAssemblyRules.xml";
				if (tibco.admin.Main.getServer().getEnv("MODE")) {
					// mode is live
					var objService = tibco.admin.Main.loadService(this.getNamespace(), rulesURI, "getServiceAssemblies");
					objService.setEndpointURL(windowshade.wsEndpointURL);
					// this setInboundURL should not be required...only here because of a current AMX framework bug
					objService.setInboundURL(dataURI);
				}
				else {
					var objService = new jsx3.net.Service(tibco.admin.Main.resolveURI(this.getNamespace(), rulesURI), "getServiceAssemblies", null, null);
					// mode is static
					objService.setInboundURL(tibco.admin.Main.resolveURI(this.getNamespace(), dataURI));
				}

				objService.browseWindowShadeObj = this;
				objService.environmentKey = envId;

				//subscribe and call
				objService.subscribe(jsx3.net.Service.ON_SUCCESS, this.ongetServiceAssembliesSuccess);
				objService.subscribe(jsx3.net.Service.ON_ERROR, this.ongetServiceAssembliesError);
				objService.subscribe(jsx3.net.Service.ON_INVALID, this.ongetServiceAssembliesInvalid);
				objService.doCall();
			};

			windowshade.prototype.ongetServiceAssembliesSuccess = function(objEvent)
			{
				//var responseXML = objEvent.target.getInboundDocument();
				//jsx3.log("Success","The service call was successful.");

				var browseWindowShadeObj = objEvent.target.browseWindowShadeObj;
				// add the "All" option to the cache
				var allServiceAssembliesLabel = tibco.admin.Main.getServer().getDynamicProperty("@MM@general@browseAllServiceAssemblies");
				browseWindowShadeObj.addAllOption(windowshade.browseServiceAssembliesCacheId, allServiceAssembliesLabel);

				browseWindowShadeObj.getDescendantOfName("serviceAssemblyList_MM_brws").repaint();
			};

			windowshade.prototype.addAllOption = function(cacheId, allText)
			{
				var cacheDoc = tibco.admin.Main.getServer().Cache.getDocument(cacheId);
				var currentTopId = cacheDoc.getFirstChild().getAttribute("jsxid");
				var recordAttrs = new Object();
				recordAttrs.jsxid = windowshade.allId;
				recordAttrs.jsxtext = allText;
				cacheDoc.insertRecordBefore(recordAttrs, currentTopId);
			}

			windowshade.prototype.ongetServiceAssembliesError = function(objEvent)
			{
				var myStatus = objEvent.target.getRequest().getStatus();
				jsx3.log("Error", "The service call failed. The HTTP Status code is: " + myStatus);
			};

			windowshade.prototype.ongetServiceAssembliesInvalid = function(objEvent)
			{
				jsx3.log("Invalid", "The following message node just failed validation:\n\n" + objEvent.message);
			};

			//call this method to begin the service call (eg.service.callgetServiceUnits();)
			windowshade.prototype.callGetServiceUnits = function(envId, serviceAssemblyId)
			{
				var dataURI = "tibco/admin/monitormanage/uicomponents/misc/browseWindowShade/data/serviceUnitData.xml";
				var rulesURI = "tibco/admin/monitormanage/uicomponents/misc/browseWindowShade/rules/serviceUnitRules.xml";
				if (tibco.admin.Main.getServer().getEnv("MODE")) {
					// mode is live
					var objService = tibco.admin.Main.loadService(this.getNamespace(), rulesURI, "getServiceUnits");
					objService.setEndpointURL(windowshade.wsEndpointURL);
					// this setInboundURL should not be required...only here because of a current AMX framework bug
					objService.setInboundURL(dataURI);
				}
				else {
					var objService = new jsx3.net.Service(tibco.admin.Main.resolveURI(this.getNamespace(), rulesURI), "getServiceUnits", null, null);
					// mode is static
					objService.setInboundURL(tibco.admin.Main.resolveURI(this.getNamespace(), dataURI));
				}

				objService.browseWindowShadeObj = this;
				objService.environmentKey = envId;
				if (serviceAssemblyId == windowshade.allId)
				{
					objService.serviceAssemblyKey = "";
				}
				else
					objService.serviceAssemblyKey = serviceAssemblyId;

				//subscribe and call
				objService.subscribe(jsx3.net.Service.ON_SUCCESS, this.ongetServiceUnitsSuccess);
				objService.subscribe(jsx3.net.Service.ON_ERROR, this.ongetServiceUnitsError);
				objService.subscribe(jsx3.net.Service.ON_INVALID, this.ongetServiceUnitsInvalid);
				objService.doCall();
			};

			windowshade.prototype.ongetServiceUnitsSuccess = function(objEvent)
			{
				//var responseXML = objEvent.target.getInboundDocument();
				//jsx3.log("Success","The service call was successful.");

				var browseWindowShadeObj = objEvent.target.browseWindowShadeObj;
				browseWindowShadeObj.getDescendantOfName("serviceUnitList_MM_brws").repaint();
			};

			windowshade.prototype.ongetServiceUnitsError = function(objEvent)
			{
				var myStatus = objEvent.target.getRequest().getStatus();
				jsx3.log("Error", "The service call failed. The HTTP Status code is: " + myStatus);
			};

			windowshade.prototype.ongetServiceUnitsInvalid = function(objEvent)
			{
				jsx3.log("Invalid", "The following message node just failed validation:\n\n" + objEvent.message);
			};

		}
		)